// themeContext.tsx
import React, { createContext, useContext, useState } from "react";
import { theme as antdTheme } from "antd";

const ThemeContext = createContext(null);

export const ThemeProvider = ({ children }) => {
  const [isDark, setIsDark] = useState(false);

  const themeConfig = {
    algorithm: isDark ? antdTheme.darkAlgorithm : antdTheme.defaultAlgorithm,
    token: {
      colorPrimary: isDark ? "#1677ff" : "#13c2c2",
    },
  };

  return (
    <ThemeContext.Provider value={{ isDark, setIsDark, themeConfig }}>
      {children}
    </ThemeContext.Provider>
  );
};

export const useTheme = () => useContext(ThemeContext);
